# 下载地址：http://chromedriver.storage.googleapis.com/index.html
# selenium之 chromedriver与chrome版本映射表
from selenium import webdriver
from time import sleep
bro = webdriver.Chrome(executable_path='./chromedriver.exe')

bro.get('http://www.taobao.com/')

# 标签定位
search_input = bro.find_element_by_id('q')
# 标签交互
search_input.send_keys('Iphone')

# 执行一组js程序
bro.execute_script('window.scrollTo(0, document.body.scrollHeight)')
sleep(2)

# 点击搜索按钮
btn = bro.find_element_by_css_selector('.btn-search')
btn.click()

bro.get('http://www.baidu.com')
sleep(2)
# 回退
bro.back()
sleep(2)
# 回退
bro.forward()

sleep(5)
bro.quit()